package com.itheima.order.service;

import com.itheima.cloud.pojo.Order;
import com.itheima.order.mapper.OrderMapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

/**
 * @Description:
 * @Version: V1.0
 */
@Service
public class OrderService {

    @Autowired
    OrderMapper orderMapper;

    public List<Order> findOrderByUserId(String username) {
        Example example = new Example(Order.class);
        Example.Criteria criteria = example.createCriteria();
        if (StringUtils.isNotEmpty(username)) {
            criteria.andEqualTo("username", username);
        }
        List<Order> orders = orderMapper.selectByExample(example);

        return orders;
    }

}
